<?php
	$challenge = $_REQUEST['challenge'];
	$userurl   = $_REQUEST['userurl'];
	$res	   = $_REQUEST['res'];
	$qs        = $_SERVER["QUERY_STRING"];
	$uamip	   = $_REQUEST['uamip'];
	$uamport   = $_REQUEST['uamport'];


	if($res == 'success'){

		header("Location: $userurl");
		print("\n</html>");
	}

	if($res == 'failed'){

		header("Location: fail.php?".$qs);
		print("\n</html>");

	}

    //Function to do the encryption thing of the password
    function return_new_pwd($pwd,$challenge,$uamsecret){
            $hex_chal   = pack('H32', $challenge);                  //Hex the challenge
            $newchal    = pack('H*', md5($hex_chal.$uamsecret));    //Add it to with $uamsecret (shared between chilli an this script)
            $response   = md5("\0" . $pwd . $newchal);              //md5 the lot
            $newpwd     = pack('a32', $pwd);                //pack again
            $password   = implode ('', unpack('H32', ($newpwd ^ $newchal))); //unpack again
            return $password;
    }

    //-- End Logon Scripts ------------

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>

<!--Graphic design by Peak 3 Design-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="open-mesh, hotel, resort, Peak 3 Design">
<title>The Capri Wifi</title>
<style type="text/css">
<!--
body,td,th {
font-family: Tahoma;
font-size: 12px;
color: #000000;
}
body {
background-color: #FFFFFF;
margin-left: 1px;
margin-top: 5px;
margin-right: 1px;
margin-bottom: 1px;
background-image: url();
background-repeat: repeat;
}
a:hover {
color: #005080;
text-decoration: none;
}
.style1 {
font-size: 16px;
font-weight: bold;
color: #CCCCCC;
}
.style3 {
font-size: 18px;
color: #662626;
}
.style4 {
font-size: 11px;
color: #000000;
}
a:link {
color: #00406A;
text-decoration: none;
}
.style5 {
font-size: 9px;
color: #000000;
}
a:visited {
color: #003F69;
text-decoration: none;
}
.style9 {
font-size: 18px;
color: #61839E;
}
a:active {
text-decoration: none;
}
.style22 {color: #000000; }
.style23 {font-size: 18px; color: #000000; }
.style24 {font-size: 9px}
-->
</style></head>
<body>
<center>
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" height="200" width="900">
<tbody>
<tr>
<td background="" valign="top">
<img src="/coova_json/img/CPR_Header.jpg" alt="Welcome!" height="200" width="900"/><br/>
</td>
</tr>
</tbody>
</table>
<table bgcolor="#ffffff" border="0" bordercolor="#000000" cellpadding="8" cellspacing="1" width="900">
<tbody>
<tr>
<td height="235" width="493">
<p class="style1 style22" align="left">Welcome to The Capri Wifi!</p>
<p class="style22" align="left">This 
network access is provided to you on behalf of the The Capri Management. We
hope you enjoy your experience. While you surf, please help us keep the
network experience great for everyone. Save large uploads and downloads
for a private connection.</p>
<p class="style22" align="left">Thanks!</p>
<p class="style22" align="left">The Capri Management</p>
</td>
<td width="5">
<p class="style3" align="left"><img src="/coova_json/img/Spacer.gif" height="100" width="5"/></p>
</td>
<td width="190">
            <form name="login" action="login.php" method="post">
                <input type="hidden" name="challenge" value="<? echo($challenge) ?>" />
                <input type="hidden" name="userurl" value="<? echo(urlencode($userurl)) ?>" />
		<input type="hidden" name="uamip" value="<? echo($uamip) ?>" />
		<input type="hidden" name="uamport" value="<? echo($uamport) ?>" />

                <label for="username" id='l_username'>Username</label> <input class="input" name="username" type="text"/>
                <br />
                <label for="password" id='l_password'>Password </label> <input class="input" name="password" type="password"/>
                <br />
                <label for="language" id='l_language'>Language </label> <select id='sel_lang' class="input" onchange="changeLanguage();">
                                                            <option value='en' selected='selected' label='English'>English</option>
                                                            <option value='af_ZA' label='Afrikaans'>Afrikaans</option>
                                                            <option value='fr_FR' label='French'>French</option>
                                                            <option value='nl_NL' label='Netherlands'>Netherlands</option>
                                                            <option value='id_ID' label='Indoensian'>Indonesian</option>
                                                            <option value='es_ES' label='Spanish'>Spanish</option>
                                                    </select>
                <br />
                <label>&nbsp; </label> <input type="submit" value="OK" class="button" />
                </form>
</tr>
</tbody>
</table>
<img src="/coova_json/img/CitySilhouette.gif" align="top" height="159" width="900"/>
<p class="style5"><span class="style24">&copy; 2011 Argentx Properties, LLC</span><br/>
</p>
</center>
</body>
</html>
